package com.situ.blog.controller;

import com.situ.blog.pojo.Blog;
import com.situ.blog.service.IBlogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
public class IndexController {

    @Autowired
    private IBlogService blogService;

    // http://localhost:8082/
    // http://localhost:8082
    @RequestMapping("/")
    public String index(Model model) {
        List<Blog> hotBlogList = blogService.selectHotBlog();
        model.addAttribute("hotBlogList", hotBlogList);

        List<Blog> blogList = blogService.selectAll();
        model.addAttribute("blogList", blogList);

        return "/WEB-INF/index.jsp";
    }
}
